<template>
  <div>
    <div class="mbo">
      <integral-banner></integral-banner>
      <!-- 行业资讯 -->
      <div class="m_information">
        <div class="in_title">
          <h4>行业资讯</h4>
          <p>让您无时无刻了解新行内资讯变动，把握同行新技巧</p>
        </div>
        <div
          class="contant"
          @click="todetail(item.id)"
          v-for="(item,index) in infomationlist"
          :key="index"
        >
          <img :src="item.cover" alt />
          <div class="right">
            <div class="right_top">
              <div class="right_top_l">{{item.title}}</div>
              <div class="right_top_r">{{item.date}}</div>
            </div>
            <div class="infodetail">
              <div v-html="item.content"></div>
            </div>
          </div>
        </div>
        <!-- 分页的 -->
        <div
          class="contant"
          @click="todetail(item.id)"
          v-for="(item,index) in infomationFlist"
          :key="index"
        >
          <img :src="item.cover" alt />
          <div class="right">
            <div class="right_top">
              <div class="right_top_l">{{item.title}}</div>
              <div class="right_top_r">{{item.date}}</div>
            </div>
            <div class="infodetail">
              <div v-html="item.content"></div>
            </div>
          </div>
        </div>
        <!-- 分页按钮 -->
        <div class="page_btn">
          <!-- <div class="prev page_btn_btn"></div> -->
          <button :class="preflag? 'changebtn':''" @click="topre" :disabled="preflag">上一页</button>
          <div class="pg">{{pagenation.current_page}} / {{pagenation.last_page}}</div>
          <!-- <div class="next page_btn_btn">下一页</div> -->
          <button :class="nextflag? 'changebtn':''" @click="tonex" :disabled="nextflag">下一页</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import integralBanner from "@/components/integralbanner/integralbanner.vue";

export default {
  components: { integralBanner },
  data() {
    return {
      infomationlist: [],
      infomationFlist: [],
      pagenation: {},
      preflag: false,
      nextflag: false
    };
  },
  mounted() {

    this.getinfolist();
    this.getFlsit();
    setTimeout(() => {
      this.jude()
    }, 100);
  },
  created () {
    
  },
  methods: {
    // 判断 是不是第一页和最后一页
    jude() {
      if (this.pagenation.current_page == this.pagenation.last_page) {
        this.nextflag = true;
      }
      window.console.log(this.pagenation.current_page,1111)
          window.console.log(this.pagenation.current_page)
          window.console.log(this.pagenation.last_page)

      if (this.pagenation.current_page == 1) {
        this.preflag = true;
      }
  
    },
    topre() {
      if (this.pagenation.current_page == 1) {
        this.preflag = true;
        return;
      }
      this.pagenation.current_page--;
    },
    tonex() {
      if (this.pagenation.current_page == this.pagenation.last_page) {
        this.nextflag = true;
        return;
      }
      this.pagenation.current_page++;
    },
    todetail(key) {
      this.$router.push("/industry/detail?id=" + key);
    },
    // 获取资讯信息
    getinfolist() {
      this.ajax("web/getFourArtic", {
        success: res => {
          // window.console.log(res);
          let infomation = res.msg;
          infomation.forEach(el => {
            let date = el.update_time;
            date = date.split(" ")[0];
            // window.console.log(date)
            el.date = date;
          });
          // window.console.log(res);
          this.infomationlist = res.msg;
          // let date = res.msg.data.update_time
          // // date =date.split(' ')
        }
      });
    },
    
    // 可以翻页的
    getFlsit() {
      this.ajax("web/getArticleList", {
        success: res => {
          let infomation = res.msg.data;
          infomation.forEach(el => {
            let date = el.update_time;
            date = date.split(" ")[0];
            // window.console.log(date)
            el.date = date;
          });
          this.infomationFlist = res.msg.data;
          this.pagenation = res.msg;
          // let date = res.msg.data.update_time
          // // date =date.split(' ')
          window.console.log(this.pagenation.current_page)

          window.console.log(this.pagenation.current_page)
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import url("../../assets/scss/industry/mindustry.css");
</style>